# -*- coding:utf-8 -*-
# @FileName  :dhcc_per_monitor.py
# @Time      :2020/12/14 10:10
# @Author    :Zhoujirong
# @Desc      :个人监控页面
from common.log import Log
from biz.flow.per_monitor import PerMonitorRequest
from biz.cases.base_case import BaseCase

class TestPerMonitor(BaseCase):
    @classmethod
    def setUpClass(cls):
        cls.cookie = BaseCase().get_token()

    def test_getqueryconfigparam(self):
        '''获取5秒内实时查询量设置'''
        ret = PerMonitorRequest.getqueryconfig(self.cookie)
        Log.info(ret)
        self.assertEqual('5',ret.param.time)
        self.assertEqual('200',ret.param.maxNum)

    def test_get_org(self):
        '''获取机构名称'''
        type = 'deptCodeName'
        ret = PerMonitorRequest.getdeptcodename(type,self.cookie)
        Log.info(ret)
        self.assertIsNotNone(ret)

    def test_get_dic(self):
        '''获取信用报告状态的字典值'''
        type = 'qryStatus'
        ret = PerMonitorRequest.getdic(type,self.cookie)
        Log.info(ret)
        self.assertEqual(8,len(ret))

    def test_get_top(self):
        '''是够是顶级机构？'''
        ret = PerMonitorRequest.istopcode(self.cookie)
        Log.info(ret)
        self.assertEqual('00000000',ret.code)
        self.assertIn('操作成功',ret.msg)

    def test_get_onedayquery(self):
        '''24小时查询量'''
        ret = PerMonitorRequest.onedayquery(self.cookie)
        Log.info(ret)
        self.assertEqual(24, len(ret.oneDayQuery.date))

    def test_get_oneweekquery(self):
        '''周查询量'''
        ret = PerMonitorRequest.oneweekquery(self.cookie)
        Log.info(ret)
        self.assertEqual(7, len(ret.weekQuery.date))

    def test_get_realtime(self):
        '''realtime?'''
        ret = PerMonitorRequest.realtime(self.cookie)
        Log.info(ret)
        self.assertIsNotNone(ret)

    def test_get_instituquery(self):
        '''机构查询量'''
        ret = PerMonitorRequest.instituquery(self.cookie)
        Log.info(ret)
        self.assertIsNotNone(ret.orgQueryNumRank.orgCode)
        self.assertIsNotNone(ret.orgQueryNumRank.series)

    def test_get_creditquery(self):
        '''征信用户查询量'''
        ret = PerMonitorRequest.creditquery(self.cookie)
        Log.info(ret)

    def test_get_internaluserquery(self):
        '''内部用户查询量'''
        ret = PerMonitorRequest.internaluserquery(self.cookie)
        Log.info(ret)
        self.assertIsNotNone(ret.innerUserQueryNumRank.orgCode)
        self.assertIsNotNone(ret.innerUserQueryNumRank.series)

    def test_get_allline(self):
        '''get_allline?'''
        ret = PerMonitorRequest.allline(self.cookie)
        Log.info(ret)

    def test_get_querystate(self):
        '''get_querystate?'''
        ret = PerMonitorRequest.querystate(self.cookie)
        Log.info(ret)

    def test_get_credituserexcep(self):
        '''征信用户查询异常'''
        ret = PerMonitorRequest.credituserexcep(self.cookie)
        Log.info(ret)
        self.assertIsNotNone(ret.creditExc.data)

    def test_get_internaluserexcep(self):
        '''内部用户查询异常'''
        ret = PerMonitorRequest.internaluserexcep(self.cookie)
        Log.info(ret)
        self.assertIsNotNone(ret.innerExc.data)






if __name__ == "__main__":
    pass